/*
 * Copyright 2008 Federal Emergency Management Agency
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0 
 *    
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 *  
 */
package gov.fema.hazus.bdc.server.dto;



import java.util.ArrayList;
import java.util.Date;

import javax.jdo.annotations.Element;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class DTO_Building  {
	
	private static final long serialVersionUID = -8107868851545145525L;
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	protected Long id;
	
    public Long getId() 
    {
        return this.id;
    }
    
    public void setId(Long id)
    {
        this.id = id;
    }
    
    @Persistent private Date lastMod;
	@Persistent private String name;
	@Persistent private String number;
	@Persistent private String abbreviation;
	
	//@Persistent(dependent = "true") 
	//private DTO_Searchable searchable;
	@Persistent 
	private ArrayList<String> terms = new ArrayList<String>();
	
	@Persistent(dependent = "true") 
	private DTO_Address address;
	
	@Persistent(dependent = "true")
	private DTO_Location location;
	
	@Persistent(dependent = "true")
	private DTO_Contact contact;
	
	@Persistent private String occupancy;
	@Persistent private String buildingType;
	@Persistent private Integer area;
	@Persistent private Integer constructionYear;
	@Persistent private Integer stories;
	
	@Persistent(dependent = "true")
	private DTO_Economy economy;
	
	@Persistent(dependent = "true")
	private DTO_Capacity capacity;
	
	@Persistent(dependent = "true")
	private DTO_Bracing bracing;
	
	@Persistent(dependent = "true")
	private DTO_EarthquakeHazard earthquakeHazard;
	
	@Persistent(dependent = "true")
	private DTO_EarthquakeBuildingDesign earthquakeBuildingDesign;
	
	@Persistent(dependent = "true")
	private DTO_EarthquakeSecondaryCharacteristics earthquakeSecondaryCharacteristics;
	
	@Persistent(dependent = "true")
	private DTO_FloodBasement floodBasement;
	
	@Persistent(dependent = "true")
	private DTO_FloodBuildingDesign floodBuildingDesign;
	
	@Persistent(dependent = "true")
	private DTO_FloodHazard floodHazard;
	
	@Persistent(dependent = "true")
	private DTO_ManufacturedHousing manufacturedHousing;
	
	@Persistent(dependent = "true")
	private DTO_Roof roof;
	
	@Persistent(dependent = "true")
	private DTO_WallsAndOpenings wallsAndOpenings;
	
	@Persistent(dependent = "true")
	private DTO_WindBuildingDesign windBuildingDesign;
	
	@Persistent(dependent = "true")
	private DTO_WindHazard windHazard;
    
	@Persistent(dependent = "true")
	private DTO_AEBMResults aebmResults;
    
	@Element(dependent = "true")
	private ArrayList<DTO_Note> notes = new ArrayList<DTO_Note>();
    
    @Persistent private String userName = "";
    @Persistent private String mode;
	
	// constants
    public static final String READ_ONLY = "read-only";
    public static final String EDITABLE = "editable"; // default
	public static final String NAME = "name";
	public static final String NUMBER = "number";
	public static final String ABBREVIATION = "abbreviation";
	public static final String OCCUPANCY = "occupancy";
	public static final String BUILDINGTYPE = "building type";
	public static final String AREA = "area";
	public static final String CONSTRUCTIONYEAR = "construction year";
	public static final String STORIES = "stories";
	
	public DTO_Building()
	{
		
		// gen
		this.address = new DTO_Address();
		this.location = new DTO_Location();
		this.contact = new DTO_Contact();
		this.economy = new DTO_Economy();
		this.capacity = new DTO_Capacity();
		
		// eq
		this.bracing = new DTO_Bracing();
		this.earthquakeHazard = new DTO_EarthquakeHazard();
		this.earthquakeBuildingDesign = new DTO_EarthquakeBuildingDesign();
		this.earthquakeSecondaryCharacteristics = new DTO_EarthquakeSecondaryCharacteristics();
		
		// fl
		this.floodBasement = new DTO_FloodBasement();
		this.floodBuildingDesign = new DTO_FloodBuildingDesign();
		this.floodHazard = new DTO_FloodHazard();
		
		// wind
		this.manufacturedHousing = new DTO_ManufacturedHousing();
		this.roof = new DTO_Roof();
		this.wallsAndOpenings = new DTO_WallsAndOpenings();
		this.windBuildingDesign = new DTO_WindBuildingDesign();
		this.windHazard = new DTO_WindHazard();
		
        this.mode = DTO_Building.EDITABLE;
		
	}

	public DTO_Building(String name, String number) {
        super();
        this.name = name;
        this.number = number;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Date getLastMod() {
		return lastMod;
	}


	public void setLastMod(Date lastMod) {
		this.lastMod = lastMod;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}
	
	public String getAbbreviation() {
		return abbreviation;
	}

	public void setAbbreviation(String abbreviation) {
		this.abbreviation = abbreviation;
	}

	public DTO_Address getAddress() {
		return address;
	}

	public void setAddress(DTO_Address address) {
		this.address = address;
	}

	public DTO_Location getLocation() {
		return location;
	}

	public void setLocation(DTO_Location location) {
		this.location = location;
	}
	
	public DTO_Contact getContact() {
		return contact;
	}

	public void setContact(DTO_Contact contact) {
		this.contact = contact;
	}

	public Integer getArea() {
		return area;
	}

	public void setArea(Integer area) {
		this.area = area;
	}

	public String getBuildingType() {
		return buildingType;
	}

	public void setBuildingType(String buildingType) {
		this.buildingType = buildingType;
	}

	public Integer getConstructionYear() {
		return constructionYear;
	}

	public void setConstructionYear(Integer constructionYear) {
		this.constructionYear = constructionYear;
	}

	public String getOccupancy() {
		return occupancy;
	}

	public void setOccupancy(String occupancy) {
		this.occupancy = occupancy;
	}

	public Integer getStories() {
		return stories;
	}

	public void setStories(Integer stories) {
		this.stories = stories;
	}

	public DTO_Economy getEconomy() {
		return economy;
	}

	public void setEconomy(DTO_Economy economy) {
		this.economy = economy;
	}

	public DTO_Capacity getCapacity() {
		return capacity;
	}

	public void setCapacity(DTO_Capacity capacity) {
		this.capacity = capacity;
	}

	public DTO_Bracing getBracing() {
		return bracing;
	}

	public void setBracing(DTO_Bracing bracing) {
		this.bracing = bracing;
	}

	public DTO_EarthquakeHazard getEarthquakeHazard() {
		return earthquakeHazard;
	}

	public void setEarthquakeHazard(DTO_EarthquakeHazard earthquakeHazard) {
		this.earthquakeHazard = earthquakeHazard;
	}

	public DTO_EarthquakeBuildingDesign getEarthquakeBuildingDesign() {
		return earthquakeBuildingDesign;
	}

	public void setEarthquakeBuildingDesign(
			DTO_EarthquakeBuildingDesign earthquakeBuildingDesign) {
		this.earthquakeBuildingDesign = earthquakeBuildingDesign;
	}

	public DTO_EarthquakeSecondaryCharacteristics getEarthquakeSecondaryCharacteristics() {
		return earthquakeSecondaryCharacteristics;
	}

	public void setEarthquakeSecondaryCharacteristics(
			DTO_EarthquakeSecondaryCharacteristics earthquakeSecondaryCharacteristics) {
		this.earthquakeSecondaryCharacteristics = earthquakeSecondaryCharacteristics;
	}

	public DTO_FloodBasement getFloodBasement() {
		return floodBasement;
	}

	public void setFloodBasement(DTO_FloodBasement floodBasement) {
		this.floodBasement = floodBasement;
	}

	public DTO_FloodBuildingDesign getFloodBuildingDesign() {
		return floodBuildingDesign;
	}

	public void setFloodBuildingDesign(DTO_FloodBuildingDesign floodBuildingDesign) {
		this.floodBuildingDesign = floodBuildingDesign;
	}

	public DTO_FloodHazard getFloodHazard() {
		return floodHazard;
	}

	public void setFloodHazard(DTO_FloodHazard floodHazard) {
		this.floodHazard = floodHazard;
	}

	public DTO_ManufacturedHousing getManufacturedHousing() {
		return manufacturedHousing;
	}

	public void setManufacturedHousing(DTO_ManufacturedHousing manufacturedHousing) {
		this.manufacturedHousing = manufacturedHousing;
	}

	public DTO_Roof getRoof() {
		return roof;
	}

	public void setRoof(DTO_Roof roof) {
		this.roof = roof;
	}

	public DTO_WallsAndOpenings getWallsAndOpenings() {
		return wallsAndOpenings;
	}

	public void setWallsAndOpenings(DTO_WallsAndOpenings wallsAndOpenings) {
		this.wallsAndOpenings = wallsAndOpenings;
	}

	public DTO_WindBuildingDesign getWindBuildingDesign() {
		return windBuildingDesign;
	}

	public void setWindBuildingDesign(DTO_WindBuildingDesign windBuildingDesign) {
		this.windBuildingDesign = windBuildingDesign;
	}

	public DTO_WindHazard getWindHazard() {
		return windHazard;
	}

	public void setWindHazard(DTO_WindHazard windHazard) {
		this.windHazard = windHazard;
	}


    /**
     * @return the mode
     */
    public String getMode() {
        return mode;
    }

    /**
     * @param mode the mode to set
     */
    public void setMode(String mode) {
        this.mode = mode;
    }

    /**
     * @return the aebmResults
     */
    public DTO_AEBMResults getAebmResults() {
        return aebmResults;
    }

    /**
     * @param aebmResults the aebmResults to set
     */
    public void setAebmResults(DTO_AEBMResults aebmResults) {
        this.aebmResults = aebmResults;
    }

    /**
     * @return the notes
     */
    public ArrayList<DTO_Note> getNotes() {
        return notes;
    }

    /**
     * @param notes the notes to set
     */
    public void setNotes(ArrayList<DTO_Note> notes) {
        this.notes = notes;
    }

    public String toString()
	{
		String str = "";
		str += "[building";
		str += "[id="+this.getId()+"]";
		//str += "[version="+this.getVersion()+"]";
        str += "[mode="+this.getMode()+"]";
        
        str += "[username="+this.getUserName()+"]";

		str += "[name="+this.name+"]";
		str += "[number="+this.number+"]";
		str += "[abbreviation="+this.abbreviation+"]";
		
		if( this.address != null )
		{
			str += this.address;
		}
		else
		{
			str += "[address=null]";
		}
        
        
		if( this.location != null )
		{
			str += this.location;
		}
		else
		{
			str += "[location=null]";
		}	
		if( this.contact != null )
		{
			str += this.contact;
		}
		else
		{
			str += "[contact=null]";
		}
		if( this.occupancy != null )
		{
			str += this.occupancy;
		}
		else
		{
			str += "[occupancy=null]";
		}	
		if( this.buildingType != null )
		{
			str += "[building-type="+this.buildingType+"]";
		}
		else
		{
			str += "[building-type=null]";
		}	
		if( this.area != null )
		{
			str += "[area="+this.area+"]";
		}
		else
		{
			str += "[area=null]";
		}
		if( this.constructionYear != null )
		{
			str += "[construction-year="+this.constructionYear+"]";
		}
		else
		{
			str += "[construction-year=null]";
		}
		if( this.stories != null )
		{
			str += "[stories="+this.stories+"]";
		}
		else
		{
			str += "[stories=null]";
		}
		if( this.economy != null )
		{
			str += this.economy;
		}
		else
		{
			str += "[economy=null]";
		}	
		if( this.capacity != null )
		{
			str += this.capacity;
		}
		else
		{
			str += "[capacity=null]";
		}	
		if( this.bracing != null )
		{
			str += this.bracing;
		}
		else
		{
			str += "[bracing=null]";
		}
		if( this.earthquakeHazard != null )
		{
			str += this.earthquakeHazard;
		}
		else
		{
			str += "[earthquake-hazard=null]";
		}
		if( this.earthquakeBuildingDesign != null )
		{
			str += this.earthquakeBuildingDesign;
		}
		else
		{
			str += "[earthquake-building-design=null]";
		}
		if( this.floodBasement != null )
		{
			str += this.floodBasement;
		}
		else
		{
			str += "[flood-basement=null]";
		}	
		if( this.floodBuildingDesign != null )
		{
			str += this.floodBuildingDesign;
		}
		else
		{
			str += "[flood-building-design=null]";
		}
		if( this.floodHazard != null )
		{
			str += this.floodHazard;
		}
		else
		{
			str += "[flood-hazard-design=null]";
		}
		if( this.manufacturedHousing != null )
		{
			str += this.manufacturedHousing;
		}
		else
		{
			str += "[manufactured-housing=null]";
		}	
		if( this.roof != null )
		{
			str += this.roof;
		}
		else
		{
			str += "[roof=null]";
		}		
		if( this.wallsAndOpenings != null )
		{
			str += this.wallsAndOpenings;
		}
		else
		{
			str += "[walls-and-openings=null]";
		}
		if( this.windBuildingDesign != null )
		{
			str += this.windBuildingDesign;
		}
		else
		{
			str += "[wind-building-design=null]";
		}		
		if( this.windHazard != null )
		{
			str += this.windHazard;
		}
		else
		{
			str += "[wind-hazard=null]";
		}		
		str += "]";
        if( this.aebmResults != null )
        {
            str += this.aebmResults;
        }
        else
        {
            str += "[aebm-results=null]";
        }    
        
        if( this.notes != null )
        {
            str += this.notes;
        }
        else
        {
            str += "[notes=null]";
        } 
        str += "]";        
		return str;
	}

	public ArrayList<String> getTerms() {
		return terms;
	}

	public void setTerms(ArrayList<String> terms) {
		this.terms = terms;
	}


}
